<template>
  <div>
    <div class="list-btn">
      <Input v-model.trim="params.name" placeholder="请输入姓名" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
      <Input v-model.trim="params.telephone" placeholder="请输入手机号" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
      <Input v-model.trim="params.order" placeholder="请输入订单号" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
      <DatePicker type="date" @on-change="startTime"  placeholder="选择开始时间" style="width: 200px" format="yyyyMMdd" ></DatePicker>
      <DatePicker type="date" @on-change="endTime"  placeholder="选择结束时间" style="width: 200px" format="yyyyMMdd" ></DatePicker>
      <Select clearable style="width:200px" v-model="params.type" placeholder="状态">
        <Option v-for="item in typeList" :value="item.name" :key="item.id">{{ item.name }}</Option>
      </Select>
      <Button type="primary" @click="getList(url,'refresh')">搜索</Button>
      <Button type="success" class="refresh-btn" @click="getList(url,'refresh')">刷新</Button>
    </div>
    <page-list :listTitle="listTitle" :list="list" :loading="loading" @selectItem="ids = $event;"></page-list>
    <page-button :current="params.pageCurrent"  :total="total" @changePageNum="params.pageCurrent = $event; getList(url)" @changePageSize="params.pageLimit = $event; getList(url)"></page-button>
    <confirm-dialog :show="showModal" @confirm="deleteItem('/aptype/delete')" @cancel="showModal.isShow = false"></confirm-dialog>
  </div>
</template>

<script>
  import listMixin from '../../mixin/list'
  import pageList from '../../template/listTemplate'
  import pageButton from '../../template/pageBtnTemplate'
  import confirmDialog from '../../template/confirmDialogTemplate'
  export default {
    mixins:[listMixin],
    components: {
      pageList,
      pageButton,
      confirmDialog
    },
    data () {
      return {

        tag: {
          'title': '转化率',
          'path': '/work/apply/list'
        },
        listTitle: [
          {
            title: '手机号',
            key: '',
            align:'left',
          },
          {
            title: '姓名',
            key: '',
            align:'left',
          },
          {
            title: '登录时间',
            key: '',
            align:'center'
          },
          {
            title: '登录IP',
            key: '',
            align:'center'
          },
          {
            title: '操作',
            key: 'action',
            width: 150,
            align: 'center',
            fixed: 'right',
            render: (h, params) => {
              return h('div', [
                h('Button', {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.editItem('/work/apEdit', 'edit', this.list[params.index])
                    }
                  }
                }, '编辑'),
                h('Button', {
                  props: {
                    type: 'error',
                    size: 'small'
                  },
                  on: {
                    click: () => {
                      this.showModal.isShow = true;
                      this.ids = this.list[params.index].id;
                    }
                  }
                }, '删除')
              ]);
            }
          }
        ],
        url: '',
        nameListUrl: '',
        params: {
          name: '',
          nameList: [],
          pageNum: 1,
          pageSize: 15
        },

      }
    },
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .list-btn{
    margin-bottom: 20px;
  }
  .refresh-btn{
    float: right;
  }

</style>
